<?php

// 本类由系统自动生成，仅供测试用途
class ThumbAction extends CommonAction {

    public function getcampaignthumb() {

        $this->assign('pagetitle', 'Get Campaign Thumb');
        $this->assign('cmCampaignThumbTActive', 'active');

        $this->display();
    }

    public function campaignthumbs() {
        
        $formData = $_POST;

        $baseThumbUrl = 'https://thumb.splio.com/';
        $thumbUrlArr = array();
        
        if(isset($formData['edmcode']) && !empty($formData['edmcode'])){

            $thumbCode = '';
            $edmCodeArr = explode("\r\n", trim($_POST['edmcode']));

            foreach ($edmCodeArr as $edmCode) {
                $edmCode = trim($edmCode);
                $key = $edmCode;

                $edmCode = preg_replace('/(.{5})(.*)/is','\1/\2',$edmCode);
                $thumbCode = preg_replace('/(.{3})(.*)/is','\1/\2',$edmCode);

                $thumbUrlArr[$key] = $baseThumbUrl . $thumbCode . '-m.png';
            }

        }

        if(isset($formData['edmurl']) && !empty($formData['edmurl'])){

            $thumbCode = '';
            $edmUrlArr = explode("\r\n", trim($formData['edmurl']));

            foreach ($edmUrlArr as $edmUrl) {
                $edmUrl = trim($edmUrl);
                $key = $edmUrl;

                $thumbCode = substr($edmUrl, 22, -1);

                $thumbUrlArr[$key] = $baseThumbUrl . $thumbCode . '-m.png';

            }
        }

        $this->assign('thumbUrlArr', $thumbUrlArr);

        $this->display();
    }
}